package com.itheima.Demo;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;

public class Demoproperties {
    public static void main(String[] args) throws IOException {
        //创建对象;
        Properties p = new Properties();
        //添加元素
        //Object setProperty(String key ,String value)
        //添加键值对
        p.setProperty("张晗","拜清清");
        p.setProperty("张梓墨","拜清清");
        p.setProperty("江疏影","拜清清");
        p.setProperty("迪丽热巴","拜清清");
        System.out.println(p);
        //String getProperty(String key)
        //根据键获取值
        //String s = p.getProperty("江疏影");
        //System.out.println(s);
        ////stringPropertyNames()
        ////获取所有的键
        //Set<String> s1 = p.stringPropertyNames();
        //System.out.println(s1);
        //store()把集合中的键值对保存到文件中
        p.store(new FileWriter("Day16codes\\aaa\\123.txt"),"helloworld");


    }
}
